package arch.coal.ellipse.security.main;


import java.io.FileInputStream;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import arch.coal.ellipse.security.dev.DataRetrieve;
import arch.coal.ellipse.security.dev.ProcessResultsOfMSF020;
import arch.coal.ellipse.security.tables.TableMSF020;
import arch.coal.ellipse.security.utils.StaticInfo;


public class Test_Main {

	   // Define a static logger variable so that it references the
	   // Logger instance named "MyApp".
	   static Logger logger = Logger.getLogger(Test_Main.class);
	   
	   public static Properties properties = null;
	   
	   
	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		   
		PropertyConfigurator.configure("log4j.properties");
		logger.debug("- Now in Test_Main.main()");
		
		properties = new Properties();
		
		if (args != null && args.length > 0) {
			properties.load( new FileInputStream(args[0]) );
			StaticInfo.setProperties(properties);
			logger.debug( " now loading properties ...");
		}
		
		TableMSF020 msf020 = new TableMSF020();
//		msf020.addWhereClause(" WHERE Entry_Type = 'G'");
//		msf020.addWhereClause(" WHERE Entry_Type = 'S'");
		msf020.addWhereClause(" WHERE Entry_Type = 'P'");
		DataRetrieve getData = new DataRetrieve(msf020, properties);
		TableMSF020 _msf020 = (TableMSF020) getData.getData();
		logger.debug("MSF020 contains [" + _msf020.getDataList().size() + "] items.");
		
		logger.debug("Here is the last record received...");
		int size = _msf020.getDataList().size();
		logger.debug( _msf020.getDataList().get(size-1).toString() );
		
		ProcessResultsOfMSF020 processMSF020 = new ProcessResultsOfMSF020();
		processMSF020.getProfileSummary(_msf020.getDataList());
		processMSF020.printSummaryList();
		
/*		
		logger.debug("Now trying with new and improved classes");
		TableMSF034 msf034 = new TableMSF034();
		msf034.addWhereClause("WHERE user_id like ('%GRANT%')");
		DataRetrieve getData2 = new DataRetrieve(msf034, properties);
		TableMSF034 _msf034 = (TableMSF034) getData2.getData();
		logger.debug("MSF034 contains [" + _msf034.getDataList().size() + "] items.");
		
		logger.debug("Now trying with new and improved classes");
		TableMSF100 msf100 = new TableMSF100();
		msf100.addWhereClause("where  stock_code > 4000000");
		DataRetrieve getData3 = new DataRetrieve(msf100, properties);
		TableMSF100 _msf100 = (TableMSF100) getData3.getData();
		logger.debug("MSF100 contains [" + _msf100.getDataList().size() + "] items.");
		
		logger.debug("Now trying with new and improved classes");
		TableMSF170 msf170 = new TableMSF170();
		msf170.addWhereClause("where  dstrct_code like ('%WEMC%')");
		DataRetrieve getData4 = new DataRetrieve(msf170, properties);
		TableMSF170 _msf170 = (TableMSF170) getData4.getData();
		logger.debug("MSF170 contains [" + _msf170.getDataList().size() + "] items.");
		*/
		
		logger.debug("LEAVING \n ===================================== \n");
	}

}
